USE [NANS21V]
GO

/****** Object:  StoredProcedure [dbo].[TimeraceList]    Script Date: 05/12/2014 08:39:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TimeraceList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[TimeraceList]
GO

CREATE PROCEDURE [dbo].[TimeraceList]
	@TAIKAINO int
AS
SELECT
	A.KYOGINO,
	A.SUBNO,
	ROUNDNO,
	KYOGIMEI,
	KIROKUFLGA,
	KIROKUFLGB,
	KIROKUKUBUN,
	SYUMOKUKUBUN
FROM
	TBL_ROUND AS A
	LEFT OUTER JOIN
	(SELECT
		B.TAIKAINO,
		B.KYOGINO,
		KYOGIMEI,
		KIROKUFLGA,
		KIROKUFLGB,
		KIROKUKUBUN,
		SYUMOKUKUBUN
	FROM
		TBL_KYOGI AS B
		LEFT OUTER JOIN TBL_SYUMOKU_MASTER AS C
		ON B.SYUMOKUNO = C.SYUMOKUNO) AS D
	ON A.KYOGINO = D.KYOGINO
	AND A.TAIKAINO = D.TAIKAINO
WHERE
	A.TAIKAINO = @TAIKAINO
	AND (ROUNDNO = 7 OR ROUNDNO = 8)
GO